package com.zxy.supplier_system.server.xinyuan.configuration

import com.qiniu.util.Auth
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.context.properties.bind.ConstructorBinding
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
@EnableConfigurationProperties(QiniuProperties::class)
class QiniuConfiguration{
    @Bean
    fun auth(qiniuProperties: QiniuProperties): Auth {
        return Auth.create(qiniuProperties.accessKey,qiniuProperties.secretKey)
    }
}

@ConfigurationProperties(prefix = "xinyuan.qiniu")
class QiniuProperties @ConstructorBinding constructor(
    val bucket: String,
    val secretKey: String,
    val accessKey: String,
)